#ifndef TC_GAME_H
#define TC_GAME_H

//#define PACKAGE_DATADIR L"../data"

#include <ode/ode.h>
#include <GL/gl.h>
#include <AL/al.h>

typedef struct
{
	struct
	{
		struct
		{
			unsigned int width;
			unsigned int height;
			float aspect;

			unsigned int frame;
		} display;

		unsigned int nfonts;
		unsigned int fonts[1];
		unsigned int fontsmat[1];

		unsigned int ntracks;
		unsigned int tracks[12];

		unsigned int tcolors[8];

		unsigned int ntoys;
		unsigned int toys[4];

		unsigned int nsfxs;
		unsigned int sfxs[8];

		unsigned int font;
		unsigned int fontmat;

		unsigned int selector;
		unsigned int sounds[3];
		unsigned int buffers[3];

		ALuint music;
	} general;

	struct
	{
		unsigned int background;

		unsigned int nstrs;
		unsigned int strs[5];

		unsigned int selection;
	} main;

	struct
	{
		unsigned int nstrs;
		unsigned int strs[9];
	} help;

	struct
	{
		unsigned int nstrs;
		unsigned int strs[7];
	} credits;

	struct
	{	
		unsigned int strs[5];

		unsigned int selection;

		struct
		{
			unsigned int x;
			unsigned int y;
			unsigned int width;
			unsigned int height;

			unsigned int fullscreen;
		} display;

		struct
		{
			unsigned int ntoys;
			unsigned int nplayers;
			unsigned int npoints;
			float speed;
			float difficulty;
			unsigned int track;
			unsigned int toy;

		} race;
	} options;

	struct
	{
		unsigned int strs[2];
	} track;

	struct
	{
		unsigned int strs[2];
	} toy;

	/*
	struct
	{
		unsigned int percentage;	
	} load;
	*/

	struct
	{
		unsigned int start;
		unsigned int string;

		float camera[3];
		unsigned int frustum;
		unsigned int track;
		unsigned int chps;
		unsigned int items;
		unsigned int toys[8];
		unsigned int bsfxs[8];

		dWorldID world;
		dSpaceID space;
		dJointGroupID joints;

		unsigned int tpoints[8];
		unsigned int tchps[8];
		unsigned int tsfxs[8][8];
		float tdistances[8];
		int titems[8];
		int tipick[8];
		int tgo[8];
		int tpads[8][5];

		unsigned int item;
		unsigned int hammer;
		unsigned int canon, ball;
		unsigned int mine;

		// remember to put the 32 to 4 or 8 at the end.
		int itoys[32];
		unsigned int itypes[32];
		unsigned int iframes[32];
		unsigned int iacts[32];
		dGeomID igeoms[32];
		dBodyID ibodies[32];
		unsigned int ichps[32];

		enum
		{
			TC_RACE_STATE_PREPARE_POINT,
			TC_RACE_STATE_FIGHT_POINT,
			TC_RACE_STATE_WIN_POINT,
			TC_RACE_STATE_WIN,
			TC_RACE_STATE_OUT
		} state;
	} race;

	enum
	{
		TC_STATE_LOAD,
		TC_STATE_UNLOAD,
		TC_STATE_MAIN,
		TC_STATE_OPTIONS,
		TC_STATE_VIDEO,
		TC_STATE_AUDIO,
		TC_STATE_SYSTEM,
		TC_STATE_HELP,
		TC_STATE_CREDITS,
		TC_STATE_PLAYERS,
		TC_STATE_TRACK,
		TC_STATE_TOY,
		TC_STATE_RACE,
		TC_STATE_CAMPAIGN,
		TC_STATE_RACE_MATCH,
		TC_STATE_RACE_TIMER,
	} state;

} TCGame;

TCGame *
tcGame(void);

void
tcGame2D(void);

void
tcGame3D(void);

#endif
